package w2

import scala.collection.mutable.ArrayBuffer

object Arr2Test {
  def main(args: Array[String]): Unit = {
    //可变长度的数组
    var ar = ArrayBuffer(1, 200, 300)
    println(ar)
    ar += 22
    println(ar)
    ar += (4, 5, 6, 8)
    println(ar)
    val a3 = ar ++ ArrayBuffer(10, 11, 12)
    println(ar)
    println(s"A3=${a3}")
    ar.insert(2, -3) //ar 不覆盖
    println(s"ar=${ar}")
    ar.remove(4, 3)
    println(s"删除后：ar=${ar}")
    ar = ar.reverse
    ar = ar.sorted
    println("排序后:")
    println(ar)
    println("颠倒后:")
    //for (i <- ar) println(i)
    ar.foreach(println)
  }
}
